Selection to Drawing API (Sel2Draw)
The Selection to Drawing API (Sel2Draw) converts graphics into a script, which is then rendered by the Macromedia Flash MX Drawing API using the generated code. This gives you a finer level of control at runtime. For example, you can desaturate or skew images made with the Drawing API, which is normally not possible with symbols or movie clips.
Using Sel2Draw
Make a selection and run the Sel2Draw command. Your selection will be replaced with code and data, which is placed in the DrawAPI folder. Your image will later appear when the movie runs.
There are some things you should consider when using Sel2Draw:
- Larger, more complex images can take a long time to render. You should start with basic images until you become familiar with how long you can expect to wait for images of different complexities to be rendered. For some images, the script may time out with a "The script has been running for a long time" error message. In this case, click Yes to continue.
- The folders created always go in the DrawAPI folder. In here you will find the _drawCode layer, followed by the drawing data layers. The data layers are named _drw0, _drw1, _drw2, ... based on the order they were created. Because the _drawCode layer must precede the data layers, running the Sel2Draw command moves it to the top, if needed. The _drw folders contain the vector data, as well as a few lines of script that will render it into a new movie clip.
- If you delete folders, they will be recreated. However if you modify your _drawCode folder, those changes will not be overwritten.
- Although you can arrange the _drw folders in any order, this will not affect the depth of the generated objects. To change this you must modify the depth directly in the code that comes after the data. These depths are generated automatically: They start at 1000 and increment as you create clips. If a _drw folder is deleted, all the data related to that image will be deleted (there is nothing extra to clean up). The newest drawing data is always inserted in the layer just under the _drawCode layer.
- The drawing data will be based on the screen position of your selected objects. If you want your data to be centered, or set to the top-left corner, move it to the desired position on the Stage before running the Sel2Draw command. The best way to do this is in the Info window (press Control-I), where you can select the position in the grid of boxes and then set both x and y to 0.
- All the selected data will be broken apart before converting, so the generated images will be flat.
- Alpha colors are not supported.
The Sel2Draw Data Format
The drawing data is stored in a series of objects, one (or more) per closed shape. These objects have the following properties:
- fill: The color or gradient color used, one per object
- origin: The starting location of the drawing; not (0,0) but, rather, the location of the first point
- records: Vector records (two types: curves and lines), distinguished by their length
- strokes: Each vector segment can have its own color, so these are stored per segment
Examples
| Fill Types | Description |
|---|---|
| fill:[0xff0088] | Solid color |
| fill:["linear... | Gradient color; follows the Drawing API definition of a gradient |
| fill:"stroke" | Shapes that are not closed (thus can't have a fill) |
| fill:-1 | Shapes that are closed but have no fill |
| fill:"donut" | Shapes that are hollow interior cutouts of other shapes |
| Stroke Type | |
|---|---|
| stroke:[[1,0x000000], null, [2,0xff0000], "-", "-"] | |
| Description | |
| [2,0xff0000] | Width of 2, RGB color of red |
| null | No stroke |
| "-" | Continuation character; stroke value doesn't change |
The drawImage Class
The drawImage class renders the shape into a movie clip. It requires a movie clip as the first parameter and a set of drawing data as its second parameter. Calls to drawImage have to occur after drawImage and after the drawing data. To render the shape on the main screen without using a movie clip, pass _root as the movie clip parameter. In this case, or in any case where all data is created in a single movie clip, the stacking order is based on the layer order (top layer on top).